/*************
Ten tac gia : LY THIEN KIM
Ngay tao : 8/16/2011
Noi dung : update 1 USER

*************/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE NAME = 'sp_UpdateUSER')
BEGIN
	DROP PROC sp_UpdateUSER
END
GO
CREATE PROC sp_UpdateUSER
	@ID				int,
	@IDROLE			int,
	@USERNAME		varchar(40),
	@PASSWORD		varchar(40),
	@SEX			int,
	@ADDRESS		varchar(40),
	@FIRSTNAME		varchar(40),
	@LASTNAME		varchar(40),
	@STATUS			int,
	@BIRTH_DATE		datetime,
	@Last_updated	datetime,
	@Result			int out
	AS
	BEGIN	
		IF EXISTS (SELECT * FROM SYS_USER WHERE ID = @ID and IDROLE = @IDROLE)
		BEGIN
			UPDATE SYS_USER SET  USERNAME = @USERNAME,PASSWORD = @PASSWORD,@SEX = @SEX,ADDRESS = @ADDRESS,FIRSTNAME = @FIRSTNAME,LASTNAME = @LASTNAME,STATUS = @STATUS,BIRTH_DATE = @BIRTH_DATE,Last_updated = @Last_updated
			WHERE ID = @ID and IDROLE = @IDROLE
			SET @Result = 1	
		END
		else
		BEGIN
			SET @Result = 0
		END
	END